package ext.wxcp.suite;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;

/**
 * 微信企业号应用套件回调消息XML定义.
 */
@XStreamAlias("xml")
public class WxCpSuiteXmlMessage {

    @XStreamAlias("SuiteId")
    @XStreamConverter(XStreamCDataConverter.class)
    private String suiteId;

    @XStreamAlias("InfoType")
    @XStreamConverter(XStreamCDataConverter.class)
    private String infoType;


    @XStreamAlias("TimeStamp")
    private Long timeStamp;

    @XStreamAlias("SuiteTicket")
    @XStreamConverter(XStreamCDataConverter.class)
    private String suiteTicket;

    @XStreamAlias("AuthCorpId")
    @XStreamConverter(XStreamCDataConverter.class)
    private String authCorpId;

    /**
     * Gets suiteTicket.
     *
     * @return Value of suiteTicket.
     */
    public String getSuiteTicket() {
        return suiteTicket;
    }

    /**
     * Sets new suiteId.
     *
     * @param suiteId New value of suiteId.
     */
    public void setSuiteId(String suiteId) {
        this.suiteId = suiteId;
    }

    /**
     * Gets infoType.
     *
     * @return Value of infoType.
     */
    public String getInfoType() {
        return infoType;
    }

    /**
     * Sets new timeStamp.
     *
     * @param timeStamp New value of timeStamp.
     */
    public void setTimeStamp(Long timeStamp) {
        this.timeStamp = timeStamp;
    }

    /**
     * Sets new suiteTicket.
     *
     * @param suiteTicket New value of suiteTicket.
     */
    public void setSuiteTicket(String suiteTicket) {
        this.suiteTicket = suiteTicket;
    }

    /**
     * Gets authCorpId.
     *
     * @return Value of authCorpId.
     */
    public String getAuthCorpId() {
        return authCorpId;
    }

    /**
     * Sets new authCorpId.
     *
     * @param authCorpId New value of authCorpId.
     */
    public void setAuthCorpId(String authCorpId) {
        this.authCorpId = authCorpId;
    }

    /**
     * Gets timeStamp.
     *
     * @return Value of timeStamp.
     */
    public Long getTimeStamp() {
        return timeStamp;
    }

    /**
     * Gets suiteId.
     *
     * @return Value of suiteId.
     */
    public String getSuiteId() {
        return suiteId;
    }

    /**
     * Sets new infoType.
     *
     * @param infoType New value of infoType.
     */
    public void setInfoType(String infoType) {
        this.infoType = infoType;
    }

    private static final XStream X_STREAM = configXStreamInstance();

    private static XStream configXStreamInstance() {
        XStream xstream = XStreamInitializer.getInstance();
        xstream.processAnnotations(WxCpSuiteXmlMessage.class);
        return xstream;
    }

    public static WxCpSuiteXmlMessage fromXml(String xml) {
        return (WxCpSuiteXmlMessage) X_STREAM.fromXML(xml);
    }

    @Override public String toString() {
        final StringBuilder sb = new StringBuilder("WxCpSuiteXmlMessage{");
        sb.append("suiteId='").append(suiteId).append('\'');
        sb.append(", infoType='").append(infoType).append('\'');
        sb.append(", timeStamp=").append(timeStamp);
        sb.append(", suiteTicket='").append(suiteTicket).append('\'');
        sb.append(", authCorpId='").append(authCorpId).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
